package com.alit.face.koala.util;

import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author litong
 * @date 2019年4月17日_下午3:03:02
 * @version 1.0
 */
public class LoggerQuene {
	// 队列大小
	public static final int QUENE_MAX_SIZE = 10000;
	// 阻塞队列
	private static LinkedBlockingQueue<LoggerMessage> quene = new LinkedBlockingQueue<>();
	// 实例
	private static LoggerQuene instance = new LoggerQuene();

	// 单例返回
	public static LoggerQuene getInstance() {
		return instance;
	}

	/**
	 * 消息入队
	 * 
	 * @param message
	 * @return
	 */
	public boolean push(LoggerMessage message) {
		boolean add = quene.add(message);
		return add;
	}

	/**
	 * 消息出队
	 * 
	 * @return
	 */
	public LoggerMessage poll() {
		LoggerMessage take = null;
		try {
			take = quene.take();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return take;
	}
}
